//
//  LCNewsHTMLDetailsVC+Create.m
//  JK九酷云头条
//
//  Created by jiukuyinyue on 2017/11/20.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LCNewsHTMLDetailsVC+Create.h"

@implementation LCNewsHTMLDetailsVC (Create)


- (UIButton*)createReloadButton:(UIView *)view {
        UIButton *reloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
        reloadButton.frame = CGRectMake(0, 0, 100, 100);
        reloadButton.center = self.view.center;
        reloadButton.layer.cornerRadius = 75.0;
        [reloadButton setBackgroundImage:[UIImage imageNamed:@"刷新"] forState:UIControlStateNormal];
        [reloadButton setTitle:@"您的网络有问题，请检查您的网络设置" forState:UIControlStateNormal];
        [reloadButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [reloadButton setTitleEdgeInsets:UIEdgeInsetsMake(200, -50, 0, -50)];
        reloadButton.titleLabel.numberOfLines = 0;
        reloadButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        CGRect rect = reloadButton.frame;
        rect.origin.y -= 100;
        reloadButton.frame = rect;
        [view addSubview: reloadButton];//

    return reloadButton;
}

- (WKWebView*)createWebView:(UIView *)view {
         WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc]init];
        config.preferences = [[WKPreferences alloc]init];
        config.userContentController = [[WKUserContentController alloc]init];
        WKWebView *webView = [[WKWebView alloc]initWithFrame:self.view.bounds configuration:config];
        webView.navigationDelegate = self;
        webView.UIDelegate = self;
        //是否允许左右划手势导航,默认不允许
        //添加此属性可触发侧滑返回上一网页与下一网页操作
        webView.allowsBackForwardNavigationGestures = YES;
        webView.scrollView.bounces = NO;//禁止WebView滚动和回弹方法
        webView.scrollView.delegate = self;
        //进度监听
        [webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL];
        [view addSubview:webView];
     return webView;
}

- (UIProgressView*)createLoadingProgressView:(UIView *)view {

    UIProgressView *loadingProgressView = [[UIProgressView alloc]initWithFrame:CGRectMake(0, self.navigationController.navigationBar.frame.size.height, [[UIScreen mainScreen] bounds].size.width, 2)];
        loadingProgressView.trackTintColor = [UIColor clearColor];
        loadingProgressView.progressTintColor = [UIColor colorWithRed:(64)/255.0 green:(181)/255.0 blue:(116)/255.0 alpha:1];
    
    [view addSubview:loadingProgressView];//
    return loadingProgressView;
}

@end
